﻿using System;
using System.Drawing;
using System.Windows.Forms;

namespace Raider.WinForms.Actions.Standard
{
    partial class AboutForm : Form
    {
        public AboutForm()
        {
            InitializeComponent();
        }

        public string Application
        {
            get { return applicationLabel.Text; }
            set
            {
                Text = "About " + value;
                applicationLabel.Text = value;
            }
        }

        public string Author
        {
            get { return authorLabel.Text; }
            set
            {
                authorLabel.Text = value;
                authorLabel.Visible = !string.IsNullOrEmpty(value);
            }
        }

        public string Copyright
        {
            get { return copyrightLabel.Text; }
            set
            {
                copyrightLabel.Text = value;
                copyrightLabel.Visible = !string.IsNullOrEmpty(value);
            }
        }

        private string version;
        public string Version
        {
            get { return version; }
            set
            {
                version = value;
                versionLabel.Text = "Version " + value;
                versionLabel.Visible = !string.IsNullOrEmpty(value);
            }
        }

        public Image Logo
        {
            get { return pictureBox.Image; }
            set { pictureBox.Image = value; }
        }

        public string AdditionalText
        {
            get { return additionalLabel.Text; }
            set
            {
                additionalLabel.Text = value;
                additionalLabel.Visible = !string.IsNullOrEmpty(value);
            }
        }

        public string LicenseText
        {
            get;
            set;
        }

        private void AboutForm_Load(object sender, EventArgs e)
        {
            Font = SystemFonts.MessageBoxFont;
        }

        private void richTextBox_LinkClicked(object sender, LinkClickedEventArgs e)
        {
            // Call Process.Start method to open a browser with link text as URL.
            System.Diagnostics.Process.Start(e.LinkText);
        }

        private void AboutForm_Shown(object sender, EventArgs e)
        {
            // RichTextBox detects links only when form is already created and shown...
            richTextBox.Text = LicenseText;
        }

        private void bevel_Paint(object sender, PaintEventArgs e)
        {
            var y = bevel.Height / 2;
            e.Graphics.DrawLine(SystemPens.ControlDark, 0, y - 1, bevel.Width, y - 1);
            e.Graphics.DrawLine(SystemPens.ControlLightLight, 0, y, bevel.Width, y);
        }
    }
}
